import jwt from 'jsonwebtoken'
import { expressjwt } from 'express-jwt'


const secretKey = "测试密码";
// 生成token
export const getToken = function (user = {}) {
    return jwt.sign(user, secretKey, {
        expiresIn: "10h",
        algorithm: 'HS256'
    })
}


// 验证token=授权判断
export const auth = function () {
    return expressjwt({
        secret: secretKey,
        algorithms: ['HS256']
    })
}